
/* #define ENTRY(x) .global x; .align; x##: */

#define HAVE_ASM_USCORE 0
#define ASM     1
#define __ASSEMBLY__     1

#include <multiboot.h>
#include <x86/platform.h>
#include <x86/asm.h>

	.extern hwp
	.extern _binary_kernel_start
	
	.text

_boot_start:
	.globl _boot_start
	jmp     multiboot_entry

	/* Align 32 bits boundary. */
	.align  4

	/* Multiboot header. */
 multiboot_header:
	/* magic */
	.long   MULTIBOOT_HEADER_MAGIC
	/* flags */
	.long   MULTIBOOT_HEADER_FLAGS
	/* checksum */
	.long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

#ifndef __ELF__
	/* header_addr */
	.long   multiboot_header
	/* load_addr */
	.long   _boot_start
	/* load_end_addr */
	.long   _edata
	/* bss_end_addr */
	.long   _end
	/* entry_addr */
	.long   multiboot_entry
#endif /* ! __ELF__ */

ENTRY(multiboot_entry)
	/* TODO: Initialize the stack pointer to right values. */
	movl	$(BOOT_STACK + STACK_SIZE), %esp

	/* Reset EFLAGS. */
	pushl   $0
	popf

	pushl 	%ebx
	pushl	_binary_brain_start

	call	load_kernel_img


	/* prepare stack for kmain() */
	pushl	$hwp
	pushl	$0x11223344

	/* Now call kmain function... */
	call	*%eax

loop:   
	hlt
	jmp     loop

ENTRY(set_cr0)
	movl	4(%esp), %eax
	movl	%eax, %cr0
	ret

ENTRY(get_cr0)
	movl	%cr0, %eax
	ret

ENTRY(set_cr3)
	movl	4(%esp), %eax
	movl	%eax, %cr3
	ret
